Left.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import { ShopItem } from "@/api/depositsApi";
  2. import clsx from "clsx";
  3. import React from "react";
  4. import styles from "./left.module.scss";
  5. interface Props {
  6. data: any;
  7. onChange?: (idx: number) => void;
  8. channelData?: any;
  9. actIdx?: number;
  10. }
  11. const Left: React.FC<Props> = ({ channelData, data, actIdx = 0, onChange }) => {
  12. const doChange = (idx: number) => {
  13. if (actIdx !== idx && typeof onChange === "function") {
  14. onChange && onChange(idx);
  15. }
  16. };
  17. return (
  18. <div className="h-[100%] overflow-auto border border-y-0 border-[#5ec5ff] shadow-[0_0_25px_#3d4083_inset]">
  19. {channelData?.name && (
  20. <div className="py-[.06rem] text-center">
  21. <img
  22. src={channelData?.icon}
  23. alt={channelData?.name}
  24. className="inline-block h-[.2rem] object-cover"
  25. />
  26. </div>
  27. )}
  28. {!!data?.length &&
  29. data.map((item: ShopItem, idx: number) => {
  30. return (
  31. <div
  32. key={`${item.id}_${idx}`}
  33. className={clsx(styles.item, { [styles.active]: actIdx === idx })}
  34. onClick={() => doChange(idx)}
  35. >
  36. {item.name}
  37. </div>
  38. );
  39. })}
  40. </div>
  41. );
  42. };
  43. export default Left;